# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'

Rails.application.load_tasks

%w[
  db:migrate
  db:rollback
  db:prepare
].each do |task_name|
  Rake::Task[task_name].enhance do
    puts "GoodJob: Sanitizing Rails version from schema.rb...\n"
    schema_rb = Rails.root.join("db/schema.rb").to_s
    contents = File.read(schema_rb)
    contents.sub!(/ActiveRecord::Schema\[\d\.\d\]/, "ActiveRecord::Schema")
    File.write(schema_rb, contents)
  end
end
